package exam.web.action;

import exam.business.service.QuestionDeleteService;
import exam.common.constant.ResultPort;
import exam.common.key.KeyQuestion;
import exam.common.util.NullCheckUtil;
import exam.web.action.base.QuestionActionBase;
/**
 * <p>DeleteQuestionAction</p>
 * <p>Action xóa câu hỏi</p>
 * 
 * @author Phong
 * @version (update: 21/5/2012)
 */
public class DeleteQuestionAction extends QuestionActionBase {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Override
	public String execute() throws Exception {
		String questionId = request.getParameter("questionId");
		if (NullCheckUtil.isNotNull(questionId)) {
			// put questionId vao serviceInfo
			serviceInfo.put(KeyQuestion.QUESTION_ID, questionId);
			// yeu cau xoa cau hoi
			QuestionDeleteService questionDeleteService = new QuestionDeleteService();
			String port = questionDeleteService.executeService(serviceInfo);
			if(ResultPort.FAIL.equals(port)) {
				addActionError("Xóa câu hỏi thất bại");
			} else {
				addActionMessage("Xóa câu hỏi thành công");
			}
			return SUCCESS;
		}
		return ERROR;
	}
}
